import { fun_login } from '@/api/index'
import { Toast } from 'vant';
import Vue from 'vue';

Vue.use(Toast)


let myLoginm = {
    namespaced: true,
    state: {
        user: []

    },
    getters: {

    },
    mutations: {
        LOGIN_DATA(state, payload) {
            state.user = JSON.parse(JSON.stringify(payload.data))
            console.log(state.user);
        }
    },
    actions: {
        LINK_DATA_AA(context, data) {
            fun_login(data).then((res) => {
                console.log(res);
                if (res.data[0].code == 200) {
                    Toast("登陆成功")
                    localStorage.setItem("token", res.data[0].token)
                    localStorage.setItem('userinfo', JSON.stringify(res.data[0].userinfo))
                }

                context.commit("LOGIN_DATA", { data: res.data })
            })
        }
    }
}
export default myLoginm